/**
 * <p>Title: MovableBackground.java</p>
 * <p>Description: CS 343 Final Project. This class is the sets the background images of the game</p>
 * @author Tim Olmstead, Brady Fetting, Erik Brown, Thales Kirk
 * @email timothy.olmstead@my.uwrf.edu, brady.fetting@my.uwrf.edu, 
 * 			erik.brown@my.uwrf.edu, thales.kirk@my.uwrf.edu
 * @date November 15, 2013
 */

package Components;

import java.awt.Image;

import javax.swing.ImageIcon;

public class MoveableBackground {
	private Image backgroundImage1;
	private Image backgroundImage2;
	private Image backClouds1;
	private Image backClouds2;
	private Image foreClouds1;
	private Image foreClouds2;
	private Image blue;

	private int x1background;
	private int y1background;
	private int x2background;
	private int y2background;
	private int x1backClouds;
	private int y1backClouds;
	private int x2backClouds;
	private int y2backClouds;
	private int x1foreClouds;
	private int y1foreClouds;
	private int x2foreClouds;
	private int y2foreClouds;

	public MoveableBackground(String f) {
		backgroundImage1 = null;
		backgroundImage2 = null;
		x1background = 0;
		y1background = 0;
		x2background = 0;
		y2background = 0;
	}

	public MoveableBackground() {
		backgroundImage1 = (new ImageIcon("src/images/background.png"))
				.getImage();
		backgroundImage2 = (new ImageIcon("src/images/background.png"))
				.getImage();
		backClouds1 = (new ImageIcon("src/images/backClouds.png")).getImage();
		backClouds2 = (new ImageIcon("src/images/backClouds.png")).getImage();
		foreClouds1 = (new ImageIcon("src/images/foregroundClouds.png"))
				.getImage();
		foreClouds2 = (new ImageIcon("src/images/foregroundClouds.png"))
				.getImage();
		blue = (new ImageIcon("src/images/blue.png")).getImage();

		x1background = 0;
		y1background = 0;
		x2background = backgroundImage1.getWidth(null);
		y2background = 0;

		x1backClouds = 0;
		y1backClouds = 0;
		x2backClouds = backClouds1.getWidth(null);
		y2backClouds = 0;

		x1foreClouds = 0;
		y1foreClouds = 0;
		x2foreClouds = foreClouds1.getWidth(null);
		y2foreClouds = 0;

	}

	public MoveableBackground(int adjustment) {
		backgroundImage1 = (new ImageIcon("src/images/background.png"))
				.getImage();
		backgroundImage2 = (new ImageIcon("src/images/background.png"))
				.getImage();
		backClouds1 = (new ImageIcon("src/images/backClouds.png")).getImage();
		backClouds2 = (new ImageIcon("src/images/backClouds.png")).getImage();
		foreClouds1 = (new ImageIcon("src/images/foregroundClouds.png"))
				.getImage();
		foreClouds2 = (new ImageIcon("src/images/foregroundClouds.png"))
				.getImage();
		blue = (new ImageIcon("src/images/blue.png")).getImage();

		x1background = -adjustment;
		y1background = 0;
		x2background = -adjustment + backgroundImage1.getWidth(null);
		y2background = 0;

		x1backClouds = 0;
		y1backClouds = 0;
		x2backClouds = backClouds1.getWidth(null);
		y2backClouds = 0;

		x1foreClouds = 0;
		y1foreClouds = 0;
		x2foreClouds = foreClouds1.getWidth(null);
		y2foreClouds = 0;

	}

	/**
	 * @returns backgroundImages1
	 */
	public Image getBackgroundImage1() {
		return backgroundImage1;
	}

	/**
	 * @param backgroundImage
	 * @description sets the backgroundimage1
	 */
	public void setBackgroundImage1(Image backgroundImage) {
		this.backgroundImage1 = backgroundImage;
	}

	/**
	 * @returns backgroundImages2
	 */
	public Image getBackgroundImage2() {
		return backgroundImage2;
	}

	/**
	 * @param backgroundImage2
	 * @description sets the backgroundimage2
	 */
	public void setBackgroundImage2(Image backgroundImage2) {
		this.backgroundImage2 = backgroundImage2;
	}

	/**
	 * @param xMoveAmount
	 * @description moves the background when called
	 */
	public void move(int xMoveAmount) {
		// background image
		x1background -= xMoveAmount;
		x2background -= xMoveAmount;
		if (x1background < (-1 * backgroundImage1.getWidth(null))) {
			x1background = x2background + backgroundImage2.getWidth(null) - 15;
		}
		if (x2background < (-1 * backgroundImage2.getWidth(null))) {
			x2background = x1background + backgroundImage1.getWidth(null) - 15;
		}

		// back clouds image
		x1backClouds -= (int) (xMoveAmount / 3);
		x2backClouds -= (int) (xMoveAmount / 3);
		if (x1backClouds < (-1 * backClouds1.getWidth(null))) {
			x1backClouds = x2backClouds + backClouds2.getWidth(null) - 15;
		}
		if (x2backClouds < (-1 * backClouds2.getWidth(null))) {
			x2backClouds = x1backClouds + backClouds1.getWidth(null) - 15;
		}

		// foreground clouds image
		x1foreClouds -= (int) ((xMoveAmount) / 3) * 2;
		x2foreClouds -= (int) ((xMoveAmount) / 3) * 2;
		if (x1foreClouds < (-1 * foreClouds1.getWidth(null))) {
			x1foreClouds = x2foreClouds + foreClouds2.getWidth(null) - 15;
		}
		if (x2foreClouds < (-1 * foreClouds2.getWidth(null))) {
			x2foreClouds = x1foreClouds + foreClouds1.getWidth(null) - 15;
		}
	}

	/**
	 * @description gets the x1Background
	 * @returns x1
	 */
	public int getX1() {
		return x1background;
	}

	/**
	 * @param x1
	 * @description sets the value for x1
	 */
	public void setX1(int x1) {
		this.x1background = x1;
	}

	/**
	 * @returns y1
	 */
	public int getY1() {
		return y1background;
	}

	/**
	 * @param y1
	 * @description sets the value for y1
	 */
	public void setY1(int y1) {
		this.y1background = y1;
	}

	/**
	 * @description gets the x2backround
	 * @returns x2
	 */
	public int getX2() {
		return x2background;
	}

	/**
	 * @param x2
	 * @description sets the value for x2
	 */
	public void setX2(int x2) {
		this.x2background = x2;
	}

	/**
	 * @returns y2
	 */
	public int getY2() {
		return y2background;
	}

	/**
	 * @param y2
	 * @description sets the value for y2
	 */
	public void setY2(int y2) {
		this.y2background = y2;
	}

	/**
	 * @param none
	 * @background returns the back clouds of the game
	 */
	public Image getBackClouds1() {
		return backClouds1;
	}

	/**
	 * @param backClouds1
	 * @description sets the backClouds
	 */
	public void setBackClouds1(Image backClouds1) {
		this.backClouds1 = backClouds1;
	}

	/**
	 * @param none
	 * @background returns the back clouds of the game
	 */
	public Image getBackClouds2() {
		return backClouds2;
	}

	/**
	 * @param backClouds2
	 * @description sets the backClouds
	 */
	public void setBackClouds2(Image backClouds2) {
		this.backClouds2 = backClouds2;
	}

	/**
	 * @param none
	 * @background returns the front clouds of the game
	 */
	public Image getForeClouds1() {
		return foreClouds1;
	}

	/**
	 * @param foreClouds1
	 * @description sets the foreClouds
	 */
	public void setForeClouds1(Image foreClouds1) {
		this.foreClouds1 = foreClouds1;
	}

	/**
	 * @param none
	 * @background returns the front clouds of the game
	 */
	public Image getForeClouds2() {
		return foreClouds2;
	}

	/**
	 * @param foreClouds2
	 * @description sets the foreClouds
	 */
	public void setForeClouds2(Image foreClouds2) {
		this.foreClouds2 = foreClouds2;
	}

	/**
	 * @param none
	 * @background returns the blue image of the game
	 */
	public Image getBlue() {
		return blue;
	}

	/**
	 * @param blue
	 * @description sets the color of the image to blue
	 */
	public void setBlue(Image blue) {
		this.blue = blue;
	}

	/**
	 * @param none
	 * @background returns the x1 back clouds of the game
	 */
	public int getX1backClouds() {
		return x1backClouds;
	}

	/**
	 * @param x1backClouds
	 * @description sets the x1 back clouds
	 */
	public void setX1backClouds(int x1backClouds) {
		this.x1backClouds = x1backClouds;
	}

	/**
	 * @param none
	 * @background returns the y1 back clouds of the game
	 */
	public int getY1backClouds() {
		return y1backClouds;
	}

	/**
	 * @param y1backClouds
	 * @description sets the y1 back clouds
	 */
	public void setY1backClouds(int y1backClouds) {
		this.y1backClouds = y1backClouds;
	}

	/**
	 * @param none
	 * @background returns the x2 back clouds of the game
	 */
	public int getX2backClouds() {
		return x2backClouds;
	}

	/**
	 * @param x2backClouds
	 * @description sets the x2 back clouds
	 */
	public void setX2backClouds(int x2backClouds) {
		this.x2backClouds = x2backClouds;
	}

	/**
	 * @param none
	 * @background returns the y2 back clouds of the game
	 */
	public int getY2backClouds() {
		return y2backClouds;
	}

	/**
	 * @param y2backClouds
	 * @description sets the y2 back clouds
	 */
	public void setY2backClouds(int y2backClouds) {
		this.y2backClouds = y2backClouds;
	}

	/**
	 * @param none
	 * @background returns the x2 front clouds of the game
	 */
	public int getX1foreClouds() {
		return x1foreClouds;
	}

	/**
	 * @param x1foreClouds
	 * @description sets the x1 front clouds
	 */
	public void setX1foreClouds(int x1foreClouds) {
		this.x1foreClouds = x1foreClouds;
	}

	/**
	 * @param none
	 * @background returns the y1 front clouds of the game
	 */
	public int getY1foreClouds() {
		return y1foreClouds;
	}

	/**
	 * @param y1foreClouds
	 * @description sets the y1 front clouds
	 */
	public void setY1foreClouds(int y1foreClouds) {
		this.y1foreClouds = y1foreClouds;
	}

	/**
	 * @param none
	 * @background returns the x2 front clouds of the game
	 */
	public int getX2foreClouds() {
		return x2foreClouds;
	}

	/**
	 * @param x2foreClouds
	 * @description sets the x2 front clouds
	 */
	public void setX2foreClouds(int x2foreClouds) {
		this.x2foreClouds = x2foreClouds;
	}

	/**
	 * @param none
	 * @background returns the y2 front clouds of the game
	 */
	public int getY2foreClouds() {
		return y2foreClouds;
	}

	/**
	 * @param y2foreClouds
	 * @description sets the y2 front clouds
	 */
	public void setY2foreClouds(int y2foreClouds) {
		this.y2foreClouds = y2foreClouds;
	}
}
